/**
 * 
 * @Project HRL Simulation
 * @Date 20.06.2011
 * @Author Aebi Pascal, Kocher Marc, Sriranjan George
 * @School BFH-TI Biel, Projekt 1
 *
 */

package utils;

import elements.Load;


public class AgendaEntry  implements Comparable<AgendaEntry>{
	
	
	private int startTime, endTime;
	private Position startPos, endPos; 
	private Load load;

	/**
	 * create a new agenda entry
	 * @param startTime start time
	 * @param startPos start position
	 * @param endTime end time 
	 * @param endPos end position
	 * @param load to put
	 */
	public AgendaEntry(int startTime, Position startPos, int endTime, Position endPos, Load load){
		this.startTime = startTime;
		this.startPos = startPos;
		this.endTime = endTime;
		this.endPos = endPos;
		this.load = load;
	}
	
	
	/**
	 * get load
	 * @return load
	 */
	public Load getLoad(){
		return load;
	}
	
	
	/**
	 * set the load
	 * @param load
	 */
	public void setLoad(Load load){
		this.load = load;
	}
	
	
	/**
	 * get the start position
	 * @return start position
	 */
	public Position getStartPosition(){
		return startPos;
	}
	
	
	/**
	 * * set the start position
	 * @param startPos start Position
	 */
	public void setStartPosition(Position startPos){
		this.startPos = startPos;
	}
	
	
	/**
	 * get start time
	 * @return start time
	 */
	public int getStartTime(){
		return startTime;
	}
	
	
	/**
	 * set start time
	 * @param startTime
	 */
	public void setStartTime(int startTime){
		this.startTime = startTime;
	}
	
	
	/**
	 * get end time
	 * @return endTime
	 */
	public int getEndTime() {
		return endTime;
	}

	
	/**
	 * set end time
	 * @param endTime
	 */
	public void setEndTime(int endTime) {
		this.endTime = endTime;
	}


	/**
	 * get end position
	 * @return Position
	 */
	public Position getEndPos() {
		return endPos;
	}


	/**
	 * set end position
	 * @param endPos
	 */
	public void setEndPos(Position endPos) {
		this.endPos = endPos;
	}


	@Override
	public int compareTo(AgendaEntry ae) {
		final int BEFORE = -1;
	    final int EQUAL = 0;
	    final int AFTER = 1;

		if(this == ae){
			return EQUAL;
		}
		if(this.getEndTime() == ae.getEndTime()){
			return EQUAL;
		}
		if(this.getEndTime() < ae.getEndTime()){
			return BEFORE;
		}else{
			return AFTER;
		}
	}
	
	
	@Override
	public String toString() {
		return String.format("starttime: %10d", this.startTime) + String.format("  endtime: %10d", this.endTime) + "  startpos: " + this.startPos + "  endpos  : " + this.endPos + "  load: " + this.load;
	}

}
